<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserBillsTable extends Migration
{
    /**
     * Run the migrations.
     *systemRefund
     * @return void
     */
    public function up()
    {
        Schema::create('user_bills', function (Blueprint $table) {
            $table->id()->comment('用户账单表');
            $table->integer('user_id')->comment('用户id')->index();
            $table->string('link_id',32)->comment('关联id');
            $table->tinyInteger('pm')->comment('账单类型: 0:支出 1:收入')->index();
            $table->string('title',64)->comment('账单标题');
            $table->string('category',64)->nullable()->comment('明细种类');
            $table->string('type')->comment('明细类型  推广订单佣金:promotionOrderCommission 推广用户佣金:promotionUserCommission 佣金提现:commissionWithdrawal
            中奖余额: winningBalance 线下收银:offlineCashier 购买会员:buyMember 购买商品:purchaseGoods 余额支付购买商品:balancePayment 商品退款:merchandiseRefund
            用户余额充值:balanceRecharge 用户分享记录:shareRecords 系统增加余额:increaseBalance 系统退款: systemRefund');
            $table->decimal('number',10,2)->nullable()->comment('账单金额');
            $table->decimal('balance',10,2)->comment('剩余金额');
            $table->string('mark')->nullable()->comment('账单备注');
            $table->string('status',50)->default('determine')->comment('账单状态:effective:有效 invalid:无效 determine:待确定');
            $table->string('take')->default(0)->comment('收获状态 0:收货 1:未收货')->index();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_bills');
    }
}
